<?php
/**
 *
 *
 */
namespace Dclub\modules\Catalog;

class Controller_Entry
    extends \Yz_Controller_Templated
    implements \Yz_Controller_Interface
{


    /**
     *
     */
    protected function doGET()
    {
        debug();
        $id = $this->fetchArgument(0);
        /*
        $model = $this->module->selectModel("TreePath");
        $itemPath = new \Yz_Array($model->fetchItemPath($id));
        $type = $itemPath[0]->name;


        $model = $this->module->selectModel("Detail");
        $model->selectItem($type);
        $item = $model
            ->fetchItemById($id);
        */

        $model = $this->module->selectModel("Detail");
        $item = $model->fetchTypedItemById($id);

        /// END new

        $template = $this->selectTemplate();
        $template->item = $item;
        $model = $this->module->selectModel("Default");
        $item0 = $model->selectItem('Short');
        $item0->assignValues($item);

        // TODO from the same cat id
        $template->prevItem = $model->fetchPreviousItem($item0);
        $template->nextItem = $model->fetchNextItem($item0);

        $this->outputTemplate($template);
        return $this;
    }


}
